import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

// 0 - n 中的每个数中，"2"出现的个数

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int l = in.nextInt();
            int r = in.nextInt();

            ArrayList<Integer> numS = new ArrayList<>();
            int count = 0;

            for (int i = l; i <= r; i++) {
                numS = splitNum(i);
                int n = Collections.frequency(numS, 2);
                count = count + n;
            }

            System.out.println(count);
        }
    }

    public static ArrayList<Integer> splitNum(Integer i) {
        if (i == 0) {
            ArrayList<Integer> arr = new ArrayList<>();
            return arr;
        }
        ArrayList<Integer> arr;
        arr = splitNum(i / 10);
        arr.add(i % 10);
        return arr;
    }
}